package io.github.rascaler.dcenter.pojo;

import io.github.rascaler.dcenter.message.BasicEcode;

import java.io.Serializable;

public class OuterResult<T> implements Serializable {
    private String code;
    private String msg;
    private T data;

    public String getCode() {
        return code;
    }

    public void setEcode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public OuterResult() {}

    public OuterResult(String code, String message) {
        this.setEcode(code);
        this.setMsg(message);
    }

    public OuterResult(String code, String message, T data) {
        this.setEcode(code);
        this.setMsg(message);
        this.setData(data);
    }

    public OuterResult success(T data) {
        return new OuterResult(BasicEcode.SUCCESS, "成功");
    }

    public static OuterResult fail(String message) {
        return new OuterResult(BasicEcode.FAILED, message);
    }


    @Override
    public String toString() {
        return "OuterResult{" +
                "code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}